package cn.itsource.system.listener;

import cn.itsource.system.service.IPermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener//申明自定义的web监听器，被容器注册和使用
@Slf4j
public class PermissionScanInitListener implements ServletContextListener {

    @Autowired
    private IPermissionService permissionService;
    
    //spring容器初始化结束之后被调用
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        System.out.println("开始扫描");
        permissionService.scanPermission();
        System.out.println("结束扫描");

    }
 
    //容器销毁的时候执行
    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
    }
}